import vue from 'vue'
import toast from './toast.vue'

const toastConstructor = vue.extend(toast);

function showToast(content){
    const toastDom = new toastConstructor({
        el: document.createElement('div'),
        data(){
            return {
                show: true,
                content: content,
            }
        }
    })

    document.body.appendChild(toastDom.$el)
    setTimeout(()=>{
        toastDom.show = false
    },4000)
}

function registToast() {
    vue.prototype.$toast = showToast
}

export default registToast